export interface FileItem {
  id?: number
  url: string
  name?: string
  alt?: string
}

export interface FilePreviewProps {
  fileList: (string | FileItem)[]
  singleSize?: number
  itemSize?: number
  maxDisplay?: number
  showDebug?: boolean
}

export interface FileTypeInfo {
  type: 'image' | 'office' | 'other'
  extension: string
  isPreviewable: boolean
}

export const getFileTypeInfo = (url: string): FileTypeInfo => {
  if (!url) return { type: 'other', extension: '', isPreviewable: false }

  const extension = url.split('.').pop()?.toLowerCase() || ''

  const imageExtensions = ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp']
  const officeExtensions = ['pdf', 'docx', 'xlsx', 'pptx']

  if (imageExtensions.includes(extension)) {
    return { type: 'image', extension, isPreviewable: true }
  }

  if (officeExtensions.includes(extension)) {
    return { type: 'office', extension, isPreviewable: true }
  }

  return { type: 'other', extension, isPreviewable: false }
}
